package com.qtcm.nas.jhx.yeji.web;

import com.qtcm.nas.jhx.chongzhi.service.IYushouservice;
import com.qtcm.nas.jhx.yeji.service.IYejiservice;
import com.qtcm.nas.jhx.yingyee.service.IYingyeeservice;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller("yejiController")
@RequestMapping("/admin/car/bosssystem")
public class YejiController {
    int money;
    int money1;
    int money2;
    int money3;
    int money4;
    int money5;
    int money6;
    int a;
    int a2;
    int a1;
    int a3;
    int a4;
    int a5;
    int a6;
    int b;
    int b1;
    int b2;
    int b3;
    int b4;
    int b5;
    int b6;
    List list = new ArrayList();
    @Resource
    private IYejiservice yejiservice;
    @Resource
    private IYushouservice yushouservice;
    @Resource
    private IYingyeeservice yingyeeservice;

    @RequestMapping(value = "qian")
    public String qian(Model model, Integer I_Revenue_name, HttpSession session) {
        list = yejiservice.qian();
        money = (int) list.get(0);
        money1 = (int) list.get(1);
        money2 = (int) list.get(2);
        money3 = (int) list.get(3);
        money4 = (int) list.get(4);
        money5 = (int) list.get(5);
        money6 = (int) list.get(6);
        System.out.println(money);
        return "redirect:chongqian";
    }

    @RequestMapping(value = "chongqian")
    public String chongqian(Model model, Integer B_rechargeamount, HttpSession session) {
        List list1 = new ArrayList();
        list1 = yushouservice.chongqian();
        a = (int) list1.get(0);
        a1 = (int) list1.get(1);
        a2 = (int) list1.get(2);
        a3 = (int) list1.get(3);
        a4 = (int) list1.get(4);
        a4 = (int) list1.get(4);
        a5 = (int) list1.get(5);
        a6 = (int) list1.get(6);
        b = a + money;
        b1 = a1 + money1;
        b2 = a2 + money2;
        b3 = a3 + money3;
        b4 = a4 + money4;
        b5 = a5 + money5;
        b6 = a6 + money6;
        session.setAttribute("b", b);
        session.setAttribute("b1", b1);
        session.setAttribute("b2", b2);
        session.setAttribute("b3", b3);
        session.setAttribute("b4", b4);
        session.setAttribute("b5", b5);
        session.setAttribute("b6", b6);
        return "redirect:jine";
    }

    @RequestMapping(value = "/jine")
    public String jine(Model model, Integer E_money, HttpSession session) {
        System.out.println("*****************");
        List list2 = yingyeeservice.jine();
        int i = (int) list2.get(0);
        int i1 = (int) list2.get(1);
        int i2 = (int) list2.get(2);
        int i3 = (int) list2.get(3);
        int i4 = (int) list2.get(4);
        int i5 = (int) list2.get(5);
        int i6 = (int) list2.get(6);
        model.addAttribute("list2", list2);
        model.addAttribute("i", i);
        model.addAttribute("i1", i1);
        model.addAttribute("i2", i2);
        model.addAttribute("i3", i3);
        model.addAttribute("i4", i4);
        model.addAttribute("i5", i5);
        model.addAttribute("i6", i6);
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
        String dateFormat = sdf.format(date);
        model.addAttribute("dateFormat",dateFormat);
        return "today_turnover";
    }
}
